function saveOrUpdateFormula(cmp, e, type) {
		var data = panel_gatherData(cmp);
		var con = new connection({
			url : 'addOrUpdateFormula.action',
			params : {
				json : Ext.encode(data)
			},
			success : function(rep, opt) {
				searchFormulaInfo();
				var alt = rep.success ? '成功' : '失败';
				Ext.Msg.alert(alt, rep.msg);
			}
		})
		con.submit();
}

function searchFormulaInfo() {
	var store = formulaGrid.getStore();
	store.load({});
}

function showFormulaUpdateWindow(){
	var win=new Ext.Window({
		modal :true,
		width:650,
		title : '修改公式',
		resizable:false,
		height:200,
		frame:true,
		id : 'updateFormulaWin_',
		buttons:[{
			text:'保存',
			handler: function(bt,e){
				var fs=win.findByType('form');
				if (fs[0].getForm().isValid()) {
					saveOrUpdateFormula(win, e, 'update');
				}
				win.destroy();
				searchFormulaInfo();
			}
		},{
			text:'返回',
			handler : function(bt, e) {
				win.destroy();
			},
			anchor: '50%'
		}],
	items:[{
		xtype : 'form',
		layout:'column',
		frame:true,
		defaults:{
			anchor: '80%',
			columnWidth:0.32,
			layout:'form',
			labelWidth:60,
			defaults:{
				anchor: '90%',
				xtype:'multiselect',
				editable : false,
				mode:"local",
				triggerAction : 'all',
				displayField : 'text',
				valueField : 'value'
			}
		},
		items:[{
			columnWidth:0.35,
			items:[{	
				xtype:'panel',
				layout:'column',
				defaults:{
					xtype:'panel',
					layout:'form'
				},
				items:[{
					columnWidth:0.64,
					labelWidth:60,
					items:[{
						anchor: '98%',
						fieldLabel:'重&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;量',
						name : 'weightFrom',
						allowBlank : true,
						id : 'weightFrom_id_win',
//						width : 50,
						xtype:'numberfield'
					}]
				},{
					columnWidth:0.36,
					labelWidth:8,
					items:[{
						anchor: '98%',
						labelSeparator:'-',
						fieldLabel:'-',
						allowBlank : true,
						name : 'weightTo',
						id : 'weightTo_id_win',
						xtype:'numberfield'
					}]
				}]
			},{
			fieldLabel:'名&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;称',
			name : 'formulaName',
			id:'formulaName_id_win',
			xtype:'textfield'
		},{
			fieldLabel:'价格比例',
			name:'rate',
			emptyText:'请输入价格比例',
			id:'rate_id_win',
			xtype : 'textfield'
		//  store:creditStore
		},{
			fieldLabel:'优先级别',
			emptyText:'请选择...',
			xtype:'combo',
			name:'importance',
			id:'importance_id_win',
			store:importStore
		}]
	},{
		items:[{
			fieldLabel:'公式种类',
			emptyText:'请选择...',
			xtype:'combo',
			name:'state',
			id:'state_id_win',
			store:formulaTypeStore
		},{
			fieldLabel:'颜&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;色',
			name:'colour',
			id:'colour_id_win',
			store:colorStore
		},{
			fieldLabel:'抛&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;光',
			name : 'buffing',
			id:'buffing_id_win',
			store:polishStore
		},{
			fieldLabel:'荧&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;光',
			name:'fluorescence',
			id:'fluorescence_id_win',
			store:lightStore
		}]
	},{
		items:[{
			fieldLabel:'对&nbsp;称&nbsp;性&nbsp;',
			id:'symmetry_id_win',
			name:'symmetry',
			store:synStore
		},{
			fieldLabel:'净&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;度',
			name:'purity',
			id:'purity_id_win',
			store:netStore
		},{
			fieldLabel:'证&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;书',
			name:'cerificate',
			id:'cerificate_id_win',
			store:creditStore
		},{
			fieldLabel:'切&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;工',
			name:'cutter',
			id:'cutter_id_win',
			store:catTypeStore
		},{
			fieldLabel:'',
			name : 'formulaId',
			id:'formulaId_id_win',
			xtype : 'textfield',
			hidden : true
		}]
	}]
	}]
})
win.show();
return win;
}
